/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vehicles;

/**
 * A JavaBean that represents a Car.
 *
 * @author jonesbr
 */
public class Car {

    private int odometer;
    private int tripOdometer;
    private double gallonsOfGas;
    private int milesPerGallon;
    private double gasConsumed;
    private static double pricePerGallon;
    private String carType;
    private boolean internalCombustion = true;

    public String toString() {
        // declare the varaible that holds the data we will return.
        String state = "Operating Cost : " + pricePerGallon * gasConsumed + " Odometer " + odometer + " Gallons of Gas: " + gallonsOfGas + " trip odometer: " + tripOdometer;


        // return the state.
        return state;

    }

    /**
     * Move the car a specified distance
     *
     * @param distance the distance we wish to move the car.
     */
    public void go(int distance) {

        // only do this if we are not a prius, or we are a prius, and we're running internalCombustion.
        if (!carType.equals("Prius") || (carType.equals("Prius") && internalCombustion)) {
            // compute the gallons of gas used.
            double gallonsOfGasUsed = distance / milesPerGallon;

            // add gallonsOfGasUsed to the running tally; gasConsumed.
            gasConsumed += gallonsOfGasUsed;

            // subtract the gallons used from the gallons available.
            gallonsOfGas = gallonsOfGas - gallonsOfGasUsed;
        } 
        
        // increase the odometer.
        odometer = odometer + distance;

        // increase the trip odometer.
        tripOdometer += distance;
    }

    /**
     * @return the odometer
     */
    public int getOdometer() {
        return odometer;
    }

    /**
     * @param odometer the odometer to set
     */
    public void setOdometer(int odometer) {
        this.odometer = odometer;
    }

    /**
     * @return the tripOdometer
     */
    public int getTripOdometer() {
        return tripOdometer;
    }

    /**
     * @param tripOdometer the tripOdometer to set
     */
    public void setTripOdometer(int tripOdometer) {
        this.tripOdometer = tripOdometer;
    }

    /**
     * @return the gallonsOfGas
     */
    public double getGallonsOfGas() {
        return gallonsOfGas;
    }

    /**
     * @param gallonsOfGas the gallonsOfGas to set
     */
    public void setGallonsOfGas(double gallonsOfGas) {
        this.gallonsOfGas = gallonsOfGas;
    }

    /**
     * @return the milesPerGallon
     */
    public int getMilesPerGallon() {
        return milesPerGallon;
    }

    /**
     * @param milesPerGallon the milesPerGallon to set
     */
    public void setMilesPerGallon(int milesPerGallon) {
        this.milesPerGallon = milesPerGallon;
    }

    /**
     * @return the gasConsumed
     */
    public double getGasConsumed() {
        return gasConsumed;
    }

    /**
     * @param gasConsumed the gasConsumed to set
     */
    public void setGasConsumed(double gasConsumed) {
        this.gasConsumed = gasConsumed;
    }

    /**
     * @return the pricePerGallon
     */
    public static double getPricePerGallon() {
        return pricePerGallon;
    }

    /**
     * @param aPricePerGallon the pricePerGallon to set
     */
    public static void setPricePerGallon(double aPricePerGallon) {
        pricePerGallon = aPricePerGallon;
    }

    /**
     * @return the carType
     */
    public String getCarType() {
        return carType;
    }

    /**
     * @param carType the carType to set
     */
    public void setCarType(String carType) {
        this.carType = carType;
    }
}
